package com.xzc.one.business.service.web;

import com.xzc.one.business.mapper.dao.web.UserDao;
import com.xzc.one.business.pojo.entity.User;
import com.xzc.one.common.inout.Page;
import com.xzc.one.common.inout.Param;
import com.xzc.one.common.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * description : user table service layer<br/>
 * time:    2020-07-04 17:21:18 <br/>
 *
 * @author xzc <br/>
 */
@Service
public class UserService {

    @Autowired
    UserDao userDao;

    public User get() {
        return userDao.queryById(1L);
    }

    public List list() {
        return ResultUtil.getList(userDao.list());
    }

    public User getUser(String userId) {
        User user = new User();
        user.setId(1);
        user.setUsername("aaa");
        user.setPassword("123");
        return user;
    }

//    public PageInfo page() {
//        PageHelper.startPage(1, 10);
//        PageInfo pageInfo = new PageInfo<>(userDao.list());
//        pageInfo.setList(ToolUtil.ResultUtil.getList(pageInfo.getList()));
//        return pageInfo;
//    }

    public Map page(Param p) {
        return Page.page(ResultUtil.getList(userDao.list()), p.pageNum, p.pageSize);
    }
}